﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using WebChatApi.Common.Interface;

namespace WebChatApi.Common
{
    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class OperatorPerformenceBinding<T> where T : IIdentifiable
    {
        #region Properties

        /// <summary>
        /// Gets or sets the operator.
        /// </summary>
        /// <value>
        /// The operator.
        /// </value>
        public T Operator
        {
            get;
            protected set;
        }

        /// <summary>
        /// Gets or sets the success count.
        /// </summary>
        /// <value>
        /// The success count.
        /// </value>
        public int SuccessCount
        {
            get;
            protected set;
        }

        /// <summary>
        /// Gets or sets the failed count.
        /// </summary>
        /// <value>
        /// The failed count.
        /// </value>
        public int FailedCount
        {
            get;
            protected set;
        }

        /// <summary>
        /// Gets the availability rank.
        /// </summary>
        /// <value>
        /// The availability rank.
        /// </value>
        public virtual double AvailabilityRank
        {
            get
            {
                return (double)SuccessCount / (double)(FailedCount + 1);
            }
        }


        #endregion

        #region Constructor

        /// <summary>
        /// Initializes a new instance of the <see cref="OperatorPerformenceMonitor{T}"/> class.
        /// </summary>
        /// <param name="operator">The operator.</param>
        public OperatorPerformenceBinding(T @operator)
        {
            this.Operator = @operator;
        }

        #endregion

        #region Public Methods

        /// <summary>
        /// Increases the success count.
        /// </summary>
        public void IncreaseSuccessCount()
        {
            this.SuccessCount += 1;
        }

        /// <summary>
        /// Increases the failed count.
        /// </summary>
        public void IncreaseFailedCount()
        {
            this.FailedCount += 1;
        }

        #endregion
    }
}
